/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 * */

// AmzServer - Tototoy's server model.
// Author: tonyjobmails@gmail.com (tonyhack).
//
// Define class ApplicationTask.
//
// ApplicationTask is a abstract unit used to communicate between application layer
// and network layer.
//

#ifndef __APPLICATION__TASK__H
#define __APPLICATION__TASK__H

#include "ring_queue_interface.h"
#include "ring_queue_define.h"

namespace amz {

class ApplicationTask {
 public:
  explicit ApplicationTask(const ring_queue_define::RingQueueConfigure &configure);
  virtual ~ApplicationTask();

  // Send/Receive message.
  int SendMessage(const char *message, int size);
  int ReceiveMessage(char *message, int max_size);

 protected:
  // Message queue.
  RingQueueInterface *message_queue_send_;
  RingQueueInterface *message_queue_receive_;

 private:
  void InitializeRingQueue(const ring_queue_define::RingQueueConfigure &configure);
  void FinalizeRingQueue();
};

}  // namespace amz

#endif  // __APPLICATION__TASK__H

